﻿using Microsoft.VisualBasic;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BakeryInventoryTesting
{
   public class BakeryItem
    {
        private string _name;
        private decimal _price;
        public string Name
        {
            get { return _name; }
            set
            {
                if (string.IsNullOrWhiteSpace(value))//判断是否为空白
                {
                    throw new ArgumentNullException("Name");//抛出错误
                }
                _name = value;//验证通过后赋值
            }
           
        }

        //public decimal Price { get; set; }
        // 例如，价格不能为负数
        public decimal Price
        {
            get { return _price; }
            set
            {
                if (value < 0)
                    throw new ArgumentException("价格不能为负数");
                _price = value;
            }
        }

        public decimal Quantity { get; set; }
        public DateTime ExpirationDate { get; set; }

        public bool IsExpired()
        {
            return DateTime.Now > ExpirationDate;
        }
    }
}
